Skip to content

[FIX] path mismatch for behavior_file_path for original baseline, resulting into empty validated test source#1513

Merged
mohammedahmed18 merged 1 commit into
mainfrom
fix/gen_test_to_no_of_tests_path_mismatch
Feb 18, 2026
Merged

[FIX] path mismatch for behavior_file_path for original baseline, resulting into empty validated test source#1513
mohammedahmed18 merged 1 commit into
mainfrom
fix/gen_test_to_no_of_tests_path_mismatch

Conversation

@mohammedahmed18
Copy link
Copy Markdown
Contributor

@mohammedahmed18 mohammedahmed18 commented Feb 18, 2026

this is a temporary fix until I find a fix for the incorrect path

[WARNING] No tests found for /home/mohammed/Work/novu/tests/test_build__unit_test_0.test.ts. existing tests: Counter({PosixPath('/home/mohammed/Work/novu/tests/../../tests/test_build__unit_test_1.test.ts'): 9, PosixPath('/home/mohammed/Work/novu/tests/../../tests/test_build__unit_test_0.test.ts'): 9})
[WARNING] No tests found for /home/mohammed/Work/novu/tests/test_build__unit_test_1.test.ts. existing tests: Counter({PosixPath('/home/mohammed/Work/novu/tests/../../tests/test_build__unit_test_1.test.ts'): 9, PosixPath('/home/mohammed/Work/novu/tests/../../tests/test_build__unit_test_0.test.ts'): 9})

the issue:
https://github.com/mohammedahmed18/novu/pull/63
the fix:
https://github.com/mohammedahmed18/novu/pull/69

Comment on lines +2080 to +2083
if any(
test_file.name == test.behavior_file_path.name and count > 0
for test_file, count in map_gen_test_file_to_no_of_tests.items()
):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (low priority): Comparing only .name (filename without directory) works because generated test filenames include the function name, test type, and iteration index — making collisions unlikely in practice. However, comparing resolved paths would be more robust:

Suggested change
if any(
test_file.name == test.behavior_file_path.name and count > 0
for test_file, count in map_gen_test_file_to_no_of_tests.items()
):
if any(
test_file.resolve() == test.behavior_file_path.resolve() and count > 0
for test_file, count in map_gen_test_file_to_no_of_tests.items()
):

This would handle symlinks, relative vs absolute paths, and other normalization differences while avoiding any theoretical false-positive matches from same-named files in different directories.

@mohammedahmed18
Copy link
Copy Markdown
Contributor Author

mohammedahmed18 commented Feb 18, 2026

this most likely happens because of the monorepo structure
the last part of the path looks like it's relative from the file inside one of the packages

@mohammedahmed18 mohammedahmed18 merged commit 8cb7209 into main Feb 18, 2026
33 of 34 checks passed
@mohammedahmed18 mohammedahmed18 deleted the fix/gen_test_to_no_of_tests_path_mismatch branch February 18, 2026 01:51
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Feb 18, 2026

PR Review Summary

Prek Checks

✅ All checks passed — ruff check and ruff format both clean, no fixes needed.

Mypy

✅ No new mypy errors introduced by this PR. The 144 pre-existing errors in function_optimizer.py are unrelated to the changed lines.

Code Review

Change: The PR fixes a silent bug where map_gen_test_file_to_no_of_tests[test.behavior_file_path] would return 0 (from Counter default) when the behavior_file_path (from test generation) didn't exactly match the Path keys in the Counter (from test result parsing), causing valid generated tests to be silently skipped in PR descriptions.

Fix approach: Compares filenames (.name) instead of full paths to handle path representation mismatches.

One suggestion posted as inline comment: Using .resolve() for full-path comparison instead of .name-only comparison would be more robust against theoretical false positives from same-named files in different directories, while still solving the path mismatch issue.

No critical bugs, security issues, or breaking API changes found.

Test Coverage

File PR Branch Main Branch Change
codeflash/optimization/function_optimizer.py 18% 18% ±0%
  • Changed lines (2080-2083): Not covered by existing tests. The changed code is inside a deep orchestration path (create_pr_comment) that is difficult to unit-test in isolation.
  • No coverage regression: Overall coverage for the file is unchanged.
  • Note: This is a modified file, not a new file, so the 75% threshold does not apply. The changed lines are in an integration-level code path.

Test Results

  • PR branch: 2374 passed, 8 failed, 57 skipped
  • Main branch: 2375 passed, 8 failed, 56 skipped
  • All 8 failures are in test_tracer.py and are pre-existing on main (not caused by this PR)

Last updated: 2026-02-18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants